package personal.hrsw.mybatisplusdemo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import personal.hrsw.mybatisplusdemo.domain.Teacher;
import personal.hrsw.mybatisplusdemo.service.TeacherService;
import personal.hrsw.mybatisplusdemo.mapper.TeacherMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Administrator
* @description 针对表【teacher】的数据库操作Service实现
* @createDate 2025-04-24 09:27:24
*/
@Service
public class TeacherServiceImpl extends ServiceImpl<TeacherMapper, Teacher>
    implements TeacherService{
    @Autowired
    TeacherMapper teacherMapper;
    @Override
    public List<Teacher> findAll() {
        return teacherMapper.selectAll();
    }
    @Override
    public int remove(int id) {
        return teacherMapper.deleteById(id);
    }

    @Override
    public int add(Teacher teacher) {
        return teacherMapper.insert(teacher);
    }

    @Override
    public Teacher findById(int id) {
        return teacherMapper.selectById(id);
    }

    @Override
    public int edit(Teacher teacher) {
        return teacherMapper.update(teacher);
    }

    @Override
    public List<Teacher> findByPage(int pageNo, int pageSize) {
        return teacherMapper.selectByPage((pageNo-1)*pageSize, pageSize);
    }

    @Override
    public boolean login(String username, String password) {
        return teacherMapper.selectByNameAndPwd(username,password)!=null;
    }
}




